#ifndef _GSTREAMERENGINE_H
#define	_GSTREAMERENGINE_H

#include <gstreamermm/init.h>
#include <gstreamermm/element.h>
#include <gstreamermm/elementfactory.h>
#include <gstreamermm/pad.h>
#include <gstreamermm/pipeline.h>
#include <gstreamermm/parse.h>
#include <gstreamermm/bin.h>
#include <gstreamermm/buffer.h>
#include <gstreamermm/bus.h>
#include <gstreamermm/interface.h>
#include <gstreamerbasemm.h>
#include <string>
#include <iostream>
using namespace std;

#include <X11/Xlib.h>

#include "mediaengine.h"

class GstreamerEngine : public MediaEngine {
public:
    void SetURL(string URL);
    void LinkToX11Window(Window window);
    void LinkToClutter();
    void Stop();
    void Play();
    void Init();

    GstreamerEngine();
    GstreamerEngine(string URL);
    virtual ~GstreamerEngine();
    
    bool GetSize(int *width, int *height);

private:
    string m_sURL;
    int xwin;
    gint m_width;
    gint m_height;
    Window m_window;
    bool change_resolution;
    Glib::RefPtr<Gst::Pipeline> m_playbin;
    Glib::RefPtr<Gst::Element> m_vsink;
    Glib::RefPtr<Gst::Element> m_lastel;


    bool on_video_pad_got_buffer(const Glib::RefPtr<Gst::Pad>& pad,
            const Glib::RefPtr<Gst::MiniObject>& data);
    void on_bus_message_sync(const Glib::RefPtr<Gst::Message>& message);
};

#endif	/* _GSTREAMERENGINE_H */

